﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine;
using Microsoft.Xna.Framework;

namespace GameBoardViewer.Animation
{
    internal class Animation
    {
        protected Position _figurePos;
        protected DateTime _timer;
        protected TimeSpan _animationLength;

        public bool Finished
        { get; set; }

        public Animation(Position figurePos, TimeSpan animationLength)
        {
            _figurePos = figurePos;
            _animationLength = animationLength;
            Finished = false;
        }

        public Position GetFigurePos()
        {
            return _figurePos;
        }

        public virtual void StartAnimation()
        {
            _timer = DateTime.Now;
        }

        protected bool GetAnimationDelta(out float delta)
        {
            delta = 0;
            TimeSpan elapsedTime = DateTime.Now - _timer;
            if (elapsedTime > _animationLength)
            {
                Finished = true;
                return false;
            }

            delta = ((float)elapsedTime.TotalMilliseconds) / (float)(_animationLength.TotalMilliseconds);
            return true;
        }

        public virtual Vector3 GetFigureAnimationPos()
        {
            return Vector3.Zero;
        }

        public virtual float GetFigureAnimationAlpha()
        {
            return 0f;
        }

        public virtual void GetRotationParameters(out float rotationX, out float rotationY)
        {
            rotationX = 0;
            rotationY = 0;
        }

    }
}
